<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // await右侧是promise对象

        // 必须配合async函数使用！
        async function fn(){
            try {
                // let n = await 123;
                let result =await new Promise((res,rej)=>{
                    // res('ok')
                    rej('失败了')
                })

                console.log(result);
            } catch (error) {
                console.log(error);
            }

            console.log("结束了");
        }

        fn()

        console.log('end');
        
        // 非promise对象 返回其结果
        // promise成功，则返回其成功结果值
        // promise失败，则抛出错误

        
    </script>
</body>

</html>